<% layout('/layouts/default.html', {title: '文件分发管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-notebook"></i> ${text('拟办领文列表')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnTake" onclick="allTakeFile()" title="${text('批量领文')}"><i class="fa fa-hand-lizard-o"></i>${text('批量领文')}</a>
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<!--
				<% if(hasPermi('sd:docDeliverRecord:edit')){ %>
					<a href="${ctx}/sd/docDeliverRecord/form" class="btn btn-default btnTool" title="${text('新增文件分发')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
				<% } %>-->
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${docDeliverRecord}" action="${ctx}/sd/docDeliverRecord/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">

			<div class="form-group">
					<label class="control-label">${text('来文自编号')}：</label>
					<div class="control-inline">

						<#form:input path="docRecv.docSysCode" maxlength="64" class="form-control width-120"/>

					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('文件标题')}：</label>
					<div class="control-inline">
						<#form:input path="docRecv.docTitle"   maxlength="4" class="form-control width-120"/>
					</div>
				</div>
			<div class="form-group">
				<label class="control-label">${text('紧急程度')}：</label>
				<div class="control-inline" style="width: 80px">
					<#form:select path="docRecv.docEmergLvl"  dictType="recv_doc_emerg_lvl" blankOption="true" class="form-control"/>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">${text('密级')}：</label>
				<div class="control-inline width-120">
					<#form:select path="docRecv.secLvl" dictType="recv_sec_lvl" blankOption="true" class="form-control"/>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">${text('领文单位')}：</label>

				<div class="control-inline width-120">
					<#form:treeselect id="unit" title="领文单位选择" path="recvUnitCode"
					url="${ctx}/sd/docDeliverRecord/treeData" class="" allowClear="true" />
				</div>
			</div>
			<!--<div class="form-group">
				<label class="control-label">${text('文件状态')}：</label>
				<div class="control-inline" style="width: 80px">
					<#form:select path="docRecv.docStatus" dictType="recv_doc_status" blankOption="true" class="form-control"/>
				</div>
			</div>-->

			<!--
				<div class="form-group">
					<label class="control-label">${text('截止领取日期')}：</label>
					<div class="control-inline">
						<#form:input path="beforeTakeDate" readonly="true" maxlength="20" class="form-control laydate width-datetime"
							dataFormat="datetime" data-type="datetime" data-format="yyyy-MM-dd HH:mm"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('截止归还日期')}：</label>
					<div class="control-inline">
						<#form:input path="beforeReturnDate" readonly="true" maxlength="20" class="form-control laydate width-datetime"
							dataFormat="datetime" data-type="datetime" data-format="yyyy-MM-dd HH:mm"/>
					</div>
				</div>

-->



				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>

	function allTakeFile(){
	  var data=	$('#dataGrid').dataGrid('getSelectRows');

	  if (data.length==0){
	  	js.layer.msg("没有选中要领取的文件",{icon:5})
	  }else{
		  js.layer.open({
			  type: 2,
			  area: [(js.layer.window.outerWidth-750)+'px',(js.layer.window.outerHeight-500)+'px'],
			  title: '${text("领取文件")}',
			  resize: false,
			  scrollbar: true,
			  maxmin:true,
			  content: '${ctx}/sd/docDeliverWaitTake/batchFile',
			  success: function(layero , index){

			  },
			  btn: ['<i class="fa fa-check"></i> ${text("保存")}',
				  '<i class="fa fa-remove"></i> ${text("关闭")}'],
			  btn1: function (index, layero) {
				  var win = layero.iframeWindow();

				  if(win.$("#userCodes").val()==''){
					  if(win.$("#pictureSrc").val()==''){
						  js.layer.msg("请先录入人脸信息",{icon:5})
						  return false;

					  }

				  }


					  if(win.$("#userName").val()==""){
						  js.layer.msg("清填写还文人姓名", {icon: 5})
						  return false;
					  }
					  if(win.$("#userPolice").val()==""){
						  js.layer.msg("清填写还文人警号", {icon: 5})
						  return false;
					  }


				  $.ajax({
					  type: "POST",
					  url: "${ctx}/sd/docDeliverRecord/batchFiles?data="+data+"&userPolice="+win.$("#userPolice").val()+"&userName="+win.$("#userName").val()+"&userCodes="+win.$("#userCodes").val(),
					 data:{"face":win.$("#pictureSrc").val()},
					  success: function (data) {
						  if(data.result===Global.TRUE){
							  js.layer.msg(data.message, {icon: 5});
							  js.layer.closeAll();
							  page()
							  return true;
						  }else{
							  js.layer.msg(data.message, {icon: 5});
							  page()
						  }
					  }
				  })
				  return false;

			  }


		  });


	}}

// 初始化DataGrid对象
  $('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	showCheckbox:true,
	columnModel: [
		{header:'${text("来文自编号")}', name:'docRecv.docSysCode', index:'c.doc_sys_code', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
			return '<a href="${ctx}/sd/docDeliverRecord/form?id='+row.id+'" class="btnList" data-title="${text("编辑文件分发")}">'+(val||row.id)+'</a>';
		}},
		{header:'${text("文件文号")}', name:'docRecv.docFullNum', index:'c.doc_full_num', width:150, align:"center"},
		{header:'${text("文件标题")}', name:'docRecv.docTitle', index:'c.doc_title', width:150, align:"center"},
		{header:'${text("来文时间")}', name:'docRecv.docRecvDate', index:'c.doc_recv_date', width:150, align:"center"},
		{header:'${text("密级")}', name:'docRecv.secLvl', index:'c.sec_lvl', width:80, align:"center", formatter: function(val, obj, row, act){
				return js.getDictLabel(${@DictUtils.getDictListJson('recv_sec_lvl')}, val, '${text("未知")}', true);
			}},
		{header:'${text("紧急程度")}', name:'docRecv.docEmergLvl', index:'c.doc_emerg_lvl', width:150, align:"center", formatter: function(val, obj, row, act){
				return js.getDictLabel(${@DictUtils.getDictListJson('recv_doc_emerg_lvl')}, val, '${text("未知")}', true);
			}},

		{header:'${text("领文单位")}', name:'office.officeName', index:'o.office_name', width:150, align:"center"},
		/*{header:'${text("文件状态")}', name:'docRecv.docStatus', index:'c.doc_status', width:150, align:"center", formatter: function(val, obj, row, act){
	return js.getDictLabel(${@DictUtils.getDictListJson('recv_doc_status')}, val, '${text("未知")}', true);
    }},*/
		{header:'${text("操作")}', name:'actions', width:65, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('sd:docDeliverRecord:edit')){ %>
				    actions.push('<a href="${ctx}/sd/docDeliverRecord/form?id='+row.id+'" class="btnList" title="${text("查看")}"><i class="fa fa-search"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;');
					//actions.push('<a href="${ctx}/sd/docDeliverRecord/take?id='+row.id+'"  class="btnList" title="${text("领文")}"><i class="icon-wallet" style="margin-left: 40%"></i></a>&nbsp;');

			<% } %>
			<% if(hasPermi('sd:docDeliverReturn:edit')){ %>
					//actions.push('<a href="${ctx}/sd/docDeliverRecord/form?id='+row.id+'" class="btnList" title="${text("编辑文件分发")}"><i class="fa fa-pencil"></i></a>&nbsp;');
					actions.push('<a href="${ctx}/sd/docDeliverRecord/take?id='+row.id+'"  class="btnList" title="${text("领文")}"><i class="fa fa-hand-lizard-o"></i></a>&nbsp;');

				<% } %>

			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});


</script>